# -*- coding: utf-8 -*-
"""
@Time: 2022/2/25 15:59
@Author: jins
@File: operateRedisCluster.py
@Introduction: 
"""
from common.mysqlDataOperate import OperateMysql
from rediscluster import RedisCluster

om = OperateMysql(version='dxy')
res = om.excute_sql(
    """select device_id ,device_code,node_type from device_center.device where short_name = 'short_name'""")
print(len(res))
rc = RedisCluster(startup_nodes=[{"host": "192.168.0.93", "port": 7001},
                                 {"host": "192.168.0.93", "port": 7002},
                                 {"host": "192.168.0.59", "port": 7003},
                                 {"host": "192.168.0.59", "port": 7004},
                                 {"host": "192.168.0.86", "port": 7005},
                                 {"host": "192.168.0.86", "port": 7006}], password='XLyf12!@')
# for item in res:
#     name = 'DEVICE_CENTER:device:' + item[0]
#     value = item[1]
#     rc.hset(name, key='device_code', value=value)
#     rc.hset(name, key='sys_type', value="1")
#     rc.hset(name, key='collect_frequence', value='mi15')
#     rc.hset(name, key='region_code', value='1')
#     rc.hset(name, key='node_type', value=item[2])

# for item in res:
#     name = 'DEVICE_CENTER:DEVICE_CODE:' + item[1]
#     value = item[0]
#     rc.set(name, value)
# count = 0
# for i in range(200074293, 200000001 + 600000):
#     rc.hset(f"DEVICE_CENTER:xnyz:{i}", "power", "1")
#     count += 1
#     if count % 1000 == 0:
#         print(count)
